from payment.balancePayment import BalancePayment
from payment.cashPayment import CashPayment
from payment.pointsPayment import PointsPayment
from payment.pointsPaymentWithWarning import PointPaymentWithWarning
from log.purchaseLog import PurchaseLog
from payment.couponPayment import CouponPayment

class PurchaseLogFactory:
    @staticmethod
    def create_log(user, product, payment_type, amount):
        payment_map = {
            "余额": BalancePayment(),
            "现金": CashPayment(),
            # "积分": PointsPayment(),
            "积分": PointPaymentWithWarning(),
            "优惠券": CouponPayment(),
        }
        if payment_type not in payment_map:
            raise ValueError("不支持的支付方式")
        return PurchaseLog(
            user.name, 
            product.display_pages, 
            payment_map[payment_type], 
            amount, 
            product, 
            product.price * amount)